public class Test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		for (int i = 0; i < 1024; i++) {
			System.out.printf("%2d %16d\n", i, toBinary(i));
		}
	}

	public static int toBinary(int a) {
		int b = 1;
		while (a > 0) {
			b *= 10;
			b += a % 2;
			a /= 2;
		}
		 return reverse(b)/10;
	}

	public static int reverse(int a) {
		int b = 0;
		while (a > 0) {
			b *= 10;
			b += (a % 10);
			a /= 10;
		}
		return b;
	}
}
